<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\DB;

class IndexController extends Controller
{
    public function index()
    {
        return view('admin/index');
    }
    public function main()
    {
        // 最新文章
        $newArticle = DB::table('articles')->orderBy('id', 'desc')->limit(6)->get();
        // 文章总数
        $count_article = DB::table('articles')->count();
        // 栏目总数
        $count_type = DB::table('types')->count();
        // 标签总数
        $count_tag = DB::table('tags')->count();
        // 专栏总数
        $count_case = DB::table('cases')->count();
        // 用户总数
        $count_user = DB::table('users')->count();
        // 评论总数
        $count_comment = DB::table("comments")->count();
        $assign = compact('newArticle', 'count_article', 'count_type', 'count_user', 'count_tag', 'count_comment','count_case');
        return view("admin/main", $assign);
    }
}
